<template>
  <div class="component_wrap">
    <LssEditor v-model="editorHtml" ref="editor" />
    <div class="val-txt">输入的值：{{ editorHtml }}</div>
  </div>
</template>
<script setup lang="ts">
import { ref, onMounted, nextTick } from 'vue'

const editorHtml = ref('<p>初始化内容</p>')
const editor = ref<any>(null)
// 模拟异步请求
const fetchEditorContent = (): Promise<string> => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve('<p>这是模拟接口出来的内容哦</p>')
    }, 2000)
  })
}

onMounted(() => {
  // todo 富文本光标在有内容时候一直在第一个 ??
  nextTick(() => {
    console.log(editor.value.editorRef, 'editorRef')
  })
  fetchEditorContent().then((content) => {
    editorHtml.value = content
  })
})
</script>
